package com.dragon.repository.domain.vo;

import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Department;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class DepartmentVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "部门id")
    private Integer id;

    @ApiModelProperty(value = "部门名称")
    private String name;

    @ApiModelProperty(value = "上级id")
    private Integer pid;

    @ApiModelProperty(value = "是否启用：1启用0禁用")
    private Integer enable;

    @ApiModelProperty(value = "部门说明")
    private String remark;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Department convert(DepartmentVO vo) {
        Department entity = new Department();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Department> convertList(List<DepartmentVO> list) {
        List<Department> resultList = new ArrayList<>();
        for (DepartmentVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
